package com.zsrt.java.day20170112.lh.daily.ch05;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

import org.junit.Test;

public class FileReadTest {
	
	@Test
	public void read() throws Exception {
		
		File file=new File("C:A.txt");
		
		
		FileReader fr=new FileReader(file);
		
		//调用api
		int len=0;
		char[] b=new char[10];
		while((len=fr.read(b))!=-1){
			String str=new String(b,0,len);
			System.out.println(str);
		}
		fr.close();
		
		
	}
	
	
	/**
	 *  输入流                输出流
	 * InputStream  OutputStream
	 * 
	 * FileInputStream FileOutputStream          字节流
	 * 
	 * Reader Writer
	 * 
	 * FileReader  FileWriter               字符流
	 * 
	 * BufferedReader BufferedWriter         
	 * 
	 * 
	 * @throws Exception
	 */
	@Test
	public void BufferedReader() throws Exception {
		
		File file=new File("C:A.txt");
		
		
		FileReader fr=new FileReader(file);
		
		BufferedReader br=new BufferedReader(fr);
		
		String str="";
		while((str=br.readLine())!=null){
			System.out.println(str);
		}
		
		
		
	}

}
